package cn.me.alphamq.nameserver.enumeration;

/**
 * 集群模式的枚举类
 *
 * @author f
 */
public enum ReplicationModeEnum {
    STANDALONE("standalone", "单机模式"),
    MASTER_SLAVE("master_slave", "主从复制模式"),
    CHAIN("chain", "链式复制模式");

    // 根据枚举的 code 属性获取枚举
    public static ReplicationModeEnum of(String code) {
        for (ReplicationModeEnum mode : ReplicationModeEnum.values()) {
            if (mode.code.equals(code)) {
                return mode;
            }
        }
        throw new RuntimeException("invalid replication mode code: " + code);
    }

    private final String code;
    private final String desc;

    ReplicationModeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
